<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');

for($i=0; $i<sizeof($this->items); $i++) : 
	$item = $this->items[$i];
	
	$db = JFactory::getDbo();
	$config = JFactory::getConfig();
	$user = JFactory::getUser();
	
	$offset = JFactory::getDate(0, 'UTC');
	$offset->setTimezone(new DateTimeZone($config->get('offset')));
		
	$today = JFactory::getDate('today', 'UTC');
	$today = JFactory::getDate(strtotime($today->toSql(true))-strtotime($offset->toSql(true)), 'UTC');
	
	$isPast = (strtotime($item->date) < strtotime($today->toSql(true))) || $item->state;
?>
	<tr class="row<?php echo $i % 2; ?> <?php echo $isPast ? "past" : 'active' ?>">
		<td class="center">
			<input type="hidden" name="id[]" value="<?php echo $item->id; ?>" />
			<?php echo JHtml::_('date', $item->date, JText::_('DATE_FORMAT_LC4')); ?>
		</td>
		<td>
			<?php echo $this->escape($item->message); ?>
		</td>
		<td class="center">
		<?php if (!$isPast) : ?>
			<a class="jgrid" href="<?php echo JRoute::_('index.php?option=com_mariageplanner&view=task&task=task.done&id='.(int) $item->id); ?>" title="<?php echo $item->state ? "Сделано" : "Выполнить" ?>"><span class="state <?php echo $item->state ? "done" : "undone" ?>"><span class="text">Статус</span></span></a>
		<?php else : ?>
			<span class="jgrid"><span class="state <?php echo $item->state ? "done" : "" ?>"><span class="text">Статус</span></span></span>
		<?php endif ?>
		</td>
		<td class="center">
		<?php if (!$isPast) : ?>
			<a class="jgrid" href="<?php echo JRoute::_('index.php?option=com_mariageplanner&view=task&id='.(int) $item->id); ?>" title="СМС напоминание"><span class="state smsstate<?php echo $item->sms_state; ?>"><span class="text">СМС</span></span></a>
		<?php endif ?>
		</td>
		<td class="center nowrap">
		<?php if(!$isPast) : ?>
			<a class="jgrid" href="<?php echo JRoute::_('index.php?option=com_mariageplanner&view=task&id='.(int) $item->id); ?>" title="Редактировать"><span class="state edit"><span class="text">Редактировать</span></span></a>
			<a class="jgrid" href="javascript:void(0);" onclick="MP_RemoveTask(this);" title="Удалить строку"><span class="state delete"><span class="text">Удалить</span></span></a>
		<?php endif; ?>
			<span class="hide"><?php echo JHtml::_('grid.id', $i, $item->id); ?></span>
		</td>
	</tr>
				
<?php endfor; ?>